@categorical fields: int → ScalarInt (pylcm #350 cascade)#10
Open
hmgaudecker wants to merge 3 commits into
Open
@categorical fields: int → ScalarInt (pylcm #350 cascade)#10hmgaudecker wants to merge 3 commits into
hmgaudecker wants to merge 3 commits into
Conversation
…alive This batches several follow-ups from the consumption-floor refactor: * Annotation sweep: every DAG function's scalar fixed_params move from Python `float`/`int`/`bool` to pylcm's post-#345 canonical scalar aliases (`ScalarFloat`, `ScalarInt`, `ScalarBool`, `Age`). Internal test helpers and analytics functions (`aime_to_pia`, `pia_to_aime`, `compute_hcc_insurer_table`) keep Python literal contracts. * Tests: switch every callsite that passed Python literals to a 0-d jax scalar, matching the post-boundary contract. * `u_alive` merges what were `u_canwork` / `u_forcedout`; leisure split three ways (`leisure_canwork_retiree_or_nongroup`, `leisure_canwork_tied`, `leisure_forcedout`). * `u_dead` deleted; `preferences.bequest` registers as the dead-regime utility directly. * `fixed_cost_of_work` extracted as a DAG function used by both `leisure_canwork_*` consumers. * `reference_hours` raised to 1000.0 (lands on the working-hours grid). * `_HCC_RHO` and `_WAGE_RHO` hoisted to module-level constants in `baseline/regimes/_common.py`. * `consumption_dollars_grid`: Python-side guard rejects collapses where the married floor would sit at or beyond the third gridpoint. * `MAX_CONSUMPTION_DOLLARS` carries a TODO pointing to pylcm#348 for routing through `fixed_params` once that lands. * `benchmark_params.pkl` regenerated to reflect the `average_consumption_equiv` key + `reference_hours=1000.0`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors the pylcm-side change: every `@categorical`-decorated class
moves its field annotations from `int` to `ScalarInt`, matching the
runtime type the decorator now produces. Touched 13 classes across
6 files (`PrefType`, `BenchmarkPrefType`, `LaborSupply`,
`LaggedLaborSupply`, `SpousalIncome`, `IsMarried`,
`HealthWithDisability`, `Health`, `GoodHealth`, `BuyPrivate`,
`HealthInsuranceState`, `ClaimedSS`, `RegimeId`).
Hashability fix: `RegimeId.<name>` is now a `jnp.int32` 0-d scalar
(unhashable), so the four `id_to_name = {getattr(RegimeId, name):
name ...}` sites in `baseline/regimes/_common.py` coerce keys with
`int(...)`. `precompute_target_regimes` likewise wraps its
`getattr(RegimeId, ...)` returns in `int(...)` so the precomputed
mapping's values can serve as dict keys and `in`-set members in
the per-target builders downstream.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Revert to @main once pylcm#350 lands so the cascade can be tested on this branch in the meantime. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Open
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@categorical-decorated class moves its field annotations frominttoScalarInt, matching the runtime type the decorator now produces. Touches 13 classes across 6 files (PrefType,BenchmarkPrefType,LaborSupply,LaggedLaborSupply,SpousalIncome,IsMarried,HealthWithDisability,Health,GoodHealth,BuyPrivate,HealthInsuranceState,ClaimedSS,RegimeId).RegimeId.<name>is now a 0-djnp.int32scalar (unhashable), so the fourid_to_name = {getattr(RegimeId, name): name ...}sites inbaseline/regimes/_common.pycoerce keys withint(...).precompute_target_regimeslikewise wraps itsgetattr(RegimeId, ...)returns inint(...)so the precomputed mapping's values serve cleanly as dict keys andin-set members downstream.@feat/categorical-scalarint; revert to@mainonce pylcm#350 merges.Test plan
pixi run -e tests-cpu pytest aca-model -n 4— 216 passed.pixi run -e type-checking ty— clean.🤖 Generated with Claude Code